home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
scrnmasm.arc
/
SCREEN.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-11-20
|
8KB
|
181 lines
DosSeg
.XList
.Model Small
.Code
Include Save.Mac
Include Restore.Mac
Include SkipLine.Mac
Public WriteCharUsingBios,WriteCharToScreen,ColorAttribute,NextLine
Public ClearScreen,HideCursor,RestoreCursor
Page ,132
.Sall
ColorAttribute db 0 ; Screen color
ScreenWidth db 79 ; Screen width-1
ScreenHeight db 24 ; Screen height-1
CursorSize dw 0607h ; Cursor setup
.List
Title Write a character to the screen
;
; This procedure will output a byte to the screen using a BIOS/Color
; output function.
; -------------------------------------------------------------------
; Input: AL=Character to output Output: None
; ColorAttribute=Color value
;
WriteCharToScreen Proc Near
Save CX ; Save register
Mov AH,ColorAttribute ; Get the color
Call WriteCharUsingBios ; Output the character
Call BiosAdvanceCursor ; And move the cursor
Restore CX ; Restore value
Ret ; Return to caller
WriteCharToScreen Endp
;
; This procedure will write to the screen (first page, one byte only)
; -------------------------------------------------------------------
; Input: AL=Character Output: None
; AH=ColorAttribute
;
WriteCharUsingBios Proc Near
Save BX,CX ; Save registers
Xor BH,BH ; Use the first page
Mov BL,AH ; Get the attribute
Mov CX,1 ; Don't repeat
Mov AH,9 ; Function for the write
Int 10h ; Call BIOS
Restore BX,CX ; Restore registers
Ret ; Return to caller
WriteCharUsingBios Endp
;
; This procedure will advance the cursor one position to the right
;------------------------------------------------------------------
; Input: None Output: None
;
BiosAdvanceCursor Proc Near
Save DX ; Save register
Call GetCursorPosition ; Get the current position
Call GetNextCursorPosition ; Point to the next one
Call PositionCursor ; And position the cursor
Restore DX ; Restore register
Ret ; Return to caller
BiosAdvanceCursor Endp
;
; This procedure will get the ROW/COLUMN where the cursor resides
; ---------------------------------------------------------------
; Input: None Output: DH=ROW, DL=COLUMN
;
GetCursorPosition Proc Near
Save AX,BX ; Save values
Mov AH,3 ; Function for get cursor
Xor BX,BX ; On this page
Int 10h ; Call BIOS
Restore AX,BX ; Restore values
Ret ; Return to caller
GetCursorPosition Endp
;
; This procedure will calculate the next row/column to place the
; cursor after a character has been output.
; --------------------------------------------------------------
; Input: DH=ROW Output: DH=NEXT ROW
; DL=COLUMN DL=NEXT COLUMN
;
GetNextCursorPosition Proc Near
Inc DL ; Point to the next column
Cmp DL,ScreenWidth ; Is it the last column ?
Jna Short CalcDone ; No..it's O.K.
Sub DL,ScreenWidth ; Get the next lines column
Dec DL ; Bit of a kludge here
Cmp DH,ScreenHeight ; Are we at the bottom ?
Jnb AtTheBottom ; Yes...
Inc DH ; Point to the next row
Jmp CalcDone ; And exit
AtTheBottom:
SkipLines 1 ; Go down a line
Xor DL,DL ; Reset column
CalcDone:
Ret ; Return to caller
GetNextCursorPosition Endp
;
; This procedure will move the cursor to a new position
; -----------------------------------------------------
; Input: DH=ROW Output: None
; DL=COLUMN
;
PositionCursor Proc Near
Save AX,BX ; Save registers
Xor BX,BX ; First video page
Mov AH,2 ; MoveCursor function
Int 10h ; Call BIOS
Restore AX,BX ; Restore values
Ret ; Return to caller
PositionCursor Endp
;
; This procedure will skip a line for scrolling
; ---------------------------------------------
; Input: None Output: None
;
NextLine Proc Near
Save AX,BX,CX,DX ; Save registers
Mov AH,6 ; Function for scrolling
Mov AL,1 ; Scroll 1 line
Mov CH,0 ; Column 1
Mov CL,0 ; Row 1
Mov BH,colorattribute ; Using the current color
Mov DH,24 ; Row 25
Mov DL,79 ; Column 80
Int 10h ; Call BIOS
Restore AX,BX,CX,DX ; Restore all registers
Ret ; Return to caller
NextLine Endp
;
; This procedure will clear the screen
; --------------------------------------------------------
; Input: ColorAttribute Output: None
;
ClearScreen Proc Near
Save AX,BX,CX,DX ; Save registers
Mov AH,15 ; Function for get video mode
Int 10h ; Put in the values
Xor AH,AH ; Function for set video mode
Int 10h ; Call BIOS
Xor BH,BH ; Indicate BG/Border setup
Mov BL,ColorAttribute ; Get the color in use
Mov CX,4 ; Setup for bit shifting
FlipBits:
Shr BX,1 ; Strip off the FG bits
Loop FlipBits ; (4 of them)
Mov AH,11 ; Function for set color palette
Int 10h ; Call BIOS
Restore AX,BX,CX,DX ; Restore values
Ret ; Return to caller
ClearScreen Endp
;
; This procedure will save the current cursor type and hide the cursor
; --------------------------------------------------------------------
; Input: None Output: CursorSize
;
HideCursor Proc Near
Save AX,BX,CX,DX ; Save registers
Call GetCursorPosition ; Get the current type
Mov CursorSize,CX ; And save it
Mov CX,2020h ; This size should hide it
Mov AH,1 ; Function for setting cursor
Int 10h ; Call BIOS
Restore AX,BX,CX,DX ; Restore values
Ret ; Return to caller
HideCursor Endp
;
; This procedure will UNDO what HideCursor did
; ----------------------------------------------------
; Input: CursorSize Output: None
;
RestoreCursor Proc Near ; Unhide the cursor
Save AX,CX ; Save registers
Mov CX,CursorSize ; Get the original size
Mov AH,1 ; Function for setting it
Int 10h ; Call Bios
Restore AX,CX ; Restore registers
Ret ; Return to caller
RestoreCursor Endp
End